#include <unistd.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#include <stdio.h>
#include <stdlib.h>

typedef struct{
  char name[20];
  int age;
}Person;

typedef struct{
  long mtype;
  Person person;
}Msg;

int main(void){
  int i;
  int msqid;
  if((msqid = msgget(0x8888,IPC_CREAT|0664) == -1)){
    perror("msgget");
  }

  Msg msg[3] = {
    {1,{"Luffy",17}},
    {1,{"Zoro",19}},
    {3,{"Bob",20}}
  };

  for(i=0;i < 3;i++){
    if(msgsnd(msqid,&msg[i],sizeof(Person),0) == -1){
      perror("msgsnd");
      break;
    }
  }
  return 0;
}
